#pragma once
#include "util.h"
#include "GameObject.h"

class PredictionArea : public GameObject
{
private:
	float ccw(const D3DXVECTOR3 p1, const D3DXVECTOR3 p2, const D3DXVECTOR3 p3);
	bool isLeftTurn(const D3DXVECTOR3 p1, const D3DXVECTOR3 p2, const D3DXVECTOR3 p3);
	bool isRightTurn(const D3DXVECTOR3 p1, const D3DXVECTOR3 p2, const D3DXVECTOR3 p3);
	bool isCollinear(const D3DXVECTOR3 p1, const D3DXVECTOR3 p2, const D3DXVECTOR3 p3);
	int createVtxDescription(void);

public:
	D3DXVECTOR3 C; // player center
	D3DXVECTOR3 L; // from playerCenter pointing in the forward direction, the left coord
	D3DXVECTOR3 R; // right coord

	float m_fBase; // angle to offset by which determines the size of the base of the triangle
	float m_fHeight; // height of the triangle

	PredictionArea(void);
	~PredictionArea(void);

	void set(const D3DXVECTOR3 playerPos, float playerAngle);
	bool contains(const D3DXVECTOR3 pos);
	void Render();

	struct DefaultVertex	*vertices;	// holds the vertices geometry
	long					*indices;	// holds the topolcoy (indices) of the geometry
	int						nVertices;
	
	D3DMATERIAL9			material;
	LPDIRECT3DTEXTURE9		texture;
	static IDirect3DVertexDeclaration9* areaDecl;
};